home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
hity wydania
/
trueSpace 7.6
/
tS761B8Std.exe
/
{app}
/
Scripts
/
D3D
/
RsD3DShadowMapRT.fx
< prev
next >
Wrap
Text File
|
2008-06-10
|
2KB
|
76 lines
uniform float4x4 mToClip : D3_MATRIX_TO_CLIP;
struct VS_MATSHADOW_IN {
float4 vPosition : POSITION; //position in object space
};
typedef struct {
float4 vPosition : POSITION;
float4 vPosition2: TEXCOORD0;
} VS_MATSHADOW_OUT;
VS_MATSHADOW_OUT VS_CMaterialShadowBuffer(in VS_MATSHADOW_IN input)
{
VS_MATSHADOW_OUT output;
output.vPosition = mul(input.vPosition, mToClip); //vertex clip position
output.vPosition2 = output.vPosition;
output.vPosition2.xy = output.vPosition2.zw;
return output;
}
float4 PS_CMaterialShadowBuffer(uniform bool bIsProjective, in VS_MATSHADOW_OUT input) : COLOR
{
float fRetVal;
if (bIsProjective)
fRetVal = input.vPosition2.x / input.vPosition2.y;
else
fRetVal = input.vPosition2.x / input.vPosition2.y;
float4 vRet;
vRet.x = fRetVal;
vRet.y = frac(fRetVal * 256.0f);
vRet.z = frac(fRetVal * 256.0f * 256.0f);
// vRet.w = 1.0f / 256.0f; //the depth bias
vRet.w = 0.0f; //the depth bias
return vRet;
}
vertexshader VS_CMaterialShadowBuffer20 = compile vs_2_0 VS_CMaterialShadowBuffer();
pixelshader PS_CMaterialShadowBuffer20 = compile ps_2_0 PS_CMaterialShadowBuffer(true);
pixelshader PS_CMaterialShadowBuffer20Dir = compile ps_2_0 PS_CMaterialShadowBuffer(false);
technique T_ShadowMapProjective {
pass P0
{
VertexShader = (VS_CMaterialShadowBuffer20);
PixelShader = (PS_CMaterialShadowBuffer20);
AlphaBlendEnable = false;
ZEnable = true;
ZFunc = LESSEQUAL;
ZWriteEnable = true;
Cullmode = CW;
// Cullmode = CCW;
}
}
technique T_ShadowMapDirectional {
pass P0
{
VertexShader = (VS_CMaterialShadowBuffer20);
PixelShader = (PS_CMaterialShadowBuffer20Dir);
AlphaBlendEnable = false;
ZEnable = true;
ZFunc = LESSEQUAL;
ZWriteEnable = true;
Cullmode = CW;
// Cullmode = CCW;
}
}